action-btn-group<template>
	<view class="container" >
		<!-- #ifdef H5 -->
		<view v-if="isWechat" style="background-color: #F5F5F5;">
			<uni-nav-bar left-icon="arrowleft"   title="团购商品信息" @click-left="back" backgroundColor="#F5F5F5"/>
		</view>
		<view v-else style="background-color: #F5F5F5;">
			<uni-nav-bar left-icon="arrowleft"  title="团购商品信息" @click-left="back" right-icon="redo"  @click-right="share1" backgroundColor="#F5F5F5"/>
		</view>
		<!-- #endif -->
		
		<view class="navbar">
			<view 
				v-for="(item, index) in navList" :key="index" 
				class="nav-item" 
				:class="{current: tabCurrentIndex === index}"
				@click="tabClick(index)"
			>
				{{item.text}}
			</view>
		</view>
		
		<swiper class="swiper-Demo" :current="tabCurrentIndex" duration="300"   @change="changeTab" @click="togglePopup('')">
			<swiper-item class="all-top" >
				<scroll-view 
					class="list-scroll-content" 
					scroll-y
					@scrolltolower="add"
				>
				<!-- 商品介绍 -->
				<view class="all" v-if="tabCurrentIndex==0" v-model="tabCurrentIndex">
					<view class="carousel">
						<swiper class="swiper" indicator-dots circular=true duration="400">
							<swiper-item class="swiper-item" v-for="(item,index) in specLists.IMAGES" :key="index">
								<view class="image-wrapper">
									<image
										:src="img+item"
										class="loaded" 
										mode="aspectFill"
										@tap="previewImagess(img+item)"
									></image>
								</view>
							</swiper-item>
						</swiper>
					</view>
					
					<view class="introduce-section" >
						<view class="un-title">
							<view class="price-box">
								<text class="price-tip">¥</text>
								<text class="price">{{specLists.GBPRICE }} 起</text>
								<text class="m-price">¥{{specLists.SELLPRICE}}</text>
								<text  class="text">已拼:{{specLists.SALECOUNT}}件</text>
							</view>
							<view >{{specLists.NAME}}</view>
							<view class="team1">
								<view class="team">
									<text class="yticon icon-shoucang_xuanzhongzhuangtai"></text>
									{{teamSize+1}}人成团
									
								</view>
								<view class="team-text" @click="navToRule">规则</view>
							</view>
						</view>
					</view>
					
					
					<!-- <view class="c-list">
						<view class="c-row b-b">
							<text class="tit">服务</text>
							<view class="bz-list con">
								<text>7天无理由退换货 ·</text>
								<text>假一赔十 ·</text>
							</view>
						</view>
					</view> -->
					<!-- 拼团信息 -->
					<view class="eva-section" v-if=" teamList.length>0">
						<view class="e-header">
							<text class="tit">这些人刚刚购买成功，可插队拼单</text>
							<text class="tip" @click="list(id,specLists.COUNTNUM)">查看更多</text>
							<text class="yticon icon-you"></text>
						</view> 
						<view class="group-list" v-for="(item, index) in teamList" :key="index">
						<!-- <view class="group-image" v-for="(item1, index1) in item.LIST" :key="index1"> -->
						    <view class="group-image"  >
						        <image class="group-image-item" :src="item.AVATOR==null ? '/static/missing-face.png':img+item.AVATOR" mode="aspectFill"></image>
						    </view>
						    <view class="attr">{{item.NAME}}</view>
						    <view class="group-text"  @click="buy(3,item.TEAMNUM)">插队拼单</view>
						    <button class="primary" type="primary" size="mini" @click="buy(3,item.TEAMNUM)">插队拼单</button>
						 </view>
						
					</view>
					<uni-popup  :show="showQr=='show'" type="middle" >
						<view class="popups">
							<view class="">扫码联系客服</view>
							<image  :src="img+specLists.QRTHUMB"  class="popupimg"></image>
							<view class="yticon icon-fork badge" @click="showQrs"></view>
						</view>
					</uni-popup>
					<!-- 评价 -->
					<view class="eva-section" v-if=" comment != 0">
						<view class="e-header">
							<text class="tit">评价</text>
							<text>({{commentsize}})</text>
							<text class="tip">更多</text>
							<text class="yticon icon-you"></text>
						</view> 
						<view class="eva-box">
							<image class="portrait" :src="comment.IMG==null ? '/static/missing-face.png' : img+comment.IMG " mode="aspectFill"></image>
							<view class="right">
								<text class="name" >{{comment.NAME}}</text>
								<text class="time">{{comment.CREATEDATE}}</text>
								<text class="con">{{comment.CONTENT}}</text>
								<view class="bot">
									<view class="attr">购买类型：{{comment.TITLE}}</view>
								</view>
								<view class="commimg">
									<view class=""  v-for="(Item, Index) in commentimg" :key="Index">
											<image @click="previewImage(Index)" class="image" :src="img+Item" style=""  mode="aspectFill"  ></image>
									</view>
								</view>
							</view>
						</view>
					</view>
					
					
					<view class="new-section m-t">
						<view class="s-header m-t" >
							<view class="tit-box" >
								<text class="tit">同类推荐</text>
							</view>
						</view>
						<scroll-view class="floor-list" scroll-x>
							<view v-if="!otherGoods||otherGoods.length==0" style="text-align: center;font-size: 25upx;color: dimgray;">暂无推荐</view>
							<view v-else class="scoll-wrapper">
								<view 
									v-for="(item, index) in otherGoods" :key="index"
									class="floor-item"
									@click="navToDetailPage(item)"
								>
									<view >
										<!-- <view class="un-huangtuoyuan">
											<text > 新品</text>
										</view> -->
										<image :src="img+ item.THUMB" mode="aspectFill"></image>
									</view>
									
									<text class="title clamp">{{item.NAME}}</text>
									<text class="tit2 title2 clamp">{{item.SHORTINFO}}</text>
									<text class="price">￥{{item.PRICE1}}</text>
								</view>
								<view class="more" @click="navToNewproductPage()">
									<text>查看全部</text>
									<text>More+</text>
								</view>
							</view>
							
						</scroll-view>
						
					</view>
					
					
					
					<!-- 规格-模态层弹窗 -->
					
				</view>
				<!-- 图片详情 -->
				<view class="all" v-if="res!= undefined || res.length == 0" >
					<view class="top">
						<view class="detail-desc">
							<view class="d-header">
								<text>图文详情</text>
							</view>
							<view style="width:100%" v-for="(item, index) in res" :key="index" >
								<img style="width:100%;display:block;" :src="img+res[index]" @tap="previewImagess(img+res[index])" />
							</view>
						</view>
					</view>
				</view>
				</scroll-view>
			</swiper-item>
			
			<swiper-item class="all-top"  >
				<scroll-view 
					class="list-scroll-content" 
					scroll-y 
				>
				<uni-popup  :show="showQr=='show'" type="middle" >
					<view class="popups">
						<view class="">扫码联系客服</view>
						<image  :src="img+specLists.QRTHUMB"  class="popupimg"></image>
						<view class="yticon icon-fork badge" @click="showQrs"></view>
					</view>
				</uni-popup>
				<!-- 图片详情 -->
				<view class="all" v-if="tabCurrentIndex==1" v-model="tabCurrentIndex">
					<view class="top">
						<view class="detail-desc">
							<view class="d-header">
								<text>图文详情</text>
							</view>
							<view style="width:100%" v-for="(item, index) in res" :key="index" >
								<img style="width:100%;display:block;" :src="img+res[index]" @tap="previewImagess(img+res[index])" />
							</view>
						</view>
						<!-- <button class="button" type="primary"  @click="share">分享有惊喜</button>
						<view class="texts">
							<view class="text">每件商品每天首次分享即可参加抽奖</view>
							<view class="text">最高100元优惠券</view>
							<view class="text">(分享后，返回亿拼惠才能抽奖哦)</view>
						</view> -->
					</view>
					<!-- <view class="buttom">
						<view class="top">注意事项</view>
						<view class="mid">
							<view class="tittle">• 购买运费如何收取？</view>
							<text class="text">单笔订单金额(不含运费)满88元免邮费；不满88元，每单收取10元运费。（港澳台地区需满500元免邮费；不满500元，每单收取30元运费)</text></view>
						<view class="mid">
							<view class="tittle">• 使用什么快递发货?</view>
							<text class="text">默认使用顺丰快递发货(个别商品使用其他快递）</text>
							<text class="text">配送范围覆盖全国大部分地区(港澳台地区除外）。</text>
						</view>
						<view class="mid">
							<view class="tittle">• 如何申请退货?</view>
							<text class="text">1.自收到商品之日起30日内，顾客可申请无忧退货，退款将原路返还，不同的银行处理时间不同，预计1-5个工作日到账；</text>
							<text class="text">2.内裤和食品等特殊商品无质量问题不支持退货；</text>
							<text class="text">3.退货流程：</text>
							<text class="text">确认收货-申请退货-客服审核通过-用户寄回商品-仓库签收验货-退款审核-退款完成；</text>
							<text class="text">4.因亿拼惠产生的退货，如质量问题，退货邮费由亿拼惠承担，退款完成后会以现金券的形式报销。因客户个人原因产生的退货，购买和寄回运费由客户个人承担。</text>
						</view>
					</view> -->
				</view>
				</scroll-view>
			</swiper-item>
		</swiper>
		
		<!-- 分享 -->
		<share 
			ref="share" 
			:contentHeight="580"
			:shareList="shareList"
		></share>
		 <!-- #ifdef H5 -->
		<uni-popup  class="" :show="type==='two'"  position="middle"  mode="fixed"   @hidePopup="togglePopup('')">
			<view class="share">
				<view class="">快喊朋友一起拼团吧</view>
				<view class="qrimg-i">
					<tki-qrcode   ref="qrcode" :val="val" :onval="onval" :size="size" :unit="unit" :loadMake="loadMake" :usingComponents="true" @result="qrR" />
				</view>
			</view>
		</uni-popup>
		<uni-popup  un="un" :show="type==='share'"  position="middle"  mode="fixed"   @hidePopup="togglePopup('')" :h5Top="h5top">
			<view style="position: absolute;top: -550upx;z-index: 1;right: -300upx;color: #FFFFFF;">
				<view class="iconfont icon-dianjiyoushangjiao" style="margin-left: 200upx;font-size: 120upx;"></view>
				<view class="share1">点击右上角分享好友</view>
			</view>
		</uni-popup>
		 <!-- #endif -->
		
			<!-- 底部操作菜单 -->
		<view class="page-bottom">
			<navigator url="/pages/index/index" open-type="switchTab" class="p-b-btn">
				<text class="yticon icon-xiatubiao--copy"></text>
				<text>首页</text>
			</navigator>
			<view class="p-b-btn" @click="showQrs">
				<text class="yticon icon-icon--" ></text>
				<text>客服</text>
			</view>
			<view class="p-b-btn" :class="{active: favorite}" @click="toFavorite">
				<text class="yticon icon-shoucang"></text>
				<text>收藏</text>
			</view>
			
			<view class="action-btn-group">
				<view class=" action-btn no-border" @click="buy(0)"  v-if="specLists.SALECOUNT!=0" >
					<view class="">¥{{specLists.SELLPRICE}}</view>
					<view class="">单独购买</view>
				</view>
				<view class=" action-btn no-border"  v-else >
				</view>
				<view class=" add-cart-btn no-border" @click="togglePopup('one')" v-if="specLists.SALECOUNT!=0" >
					<view class="">¥{{specLists.GBPRICE }}</view>
					<view class="">拼团</view>
				</view>
				<view class=" add-cart-btn1 no-border" @click="buy(1)" v-else>
					<view class="">¥{{specLists.GBPRICE }}</view>
					<view class="">发起拼团</view>
				</view>
			</view>
		</view>
		<!-- <uni-popup  :show="type==='one'"  position="middle"  mode="fixed"   @hidePopup="togglePopup('')">
			<view class="form">
				<view class=" add-cart-btn no-border" @click="buy(1)" >
					<text class="text">拼团</text>
				</view>
				<view class=" add-cart-btn no-border" @click="buy(2)" >
					<text class="text">开团</text>
				</view>
			</view>
		</uni-popup> -->
		<view class="form" v-if="type == 'one'"  >
			<view class=" add-cart-btn no-border" @click="buy(1)" >
				<text class="text">拼团</text>
			</view>
			<view class=" add-cart-btn no-border" @click="buy(2)" >
				<text class="text">开团</text>
			</view>
		</view>
		
		
	</view>
</template>

<script>
	import {  
	    mapMutations  
	} from 'vuex';
	import uniNumberBox from '@/components/uni-number-box/uni-number-box.vue'
	import share from '@/components/share';
	import uniCountdown from '@/components/uni-countdown/uni-countdown.vue';
	import uniPopup from '@/components/uni-popup/uni-popup.vue';
	// #ifdef H5
	import uniIcons from '@/components/uni-icons/uni-icons.vue'
	import uniNavBar from '@/components/uni-nav-bar/uni-nav-bar.vue'
	import tkiQrcode from '@/components/tki-qrcode/tki-qrcode.vue'  //仅H5
	var jweixin = require('../../common/jweixin-1.4.0.js');
	// #endif
	
	export default{
		components: {
			share,
			uniNumberBox,
			uniCountdown,
			uniPopup,
			// #ifdef H5
			tkiQrcode,
			uniIcons,
			uniNavBar
			// #endif
			
		},
		data() {
			return {
				isWechat:true,
				h5top:true,
				num : 1,
				id : '',
				SIGNATURE: '',
				tabCurrentIndex: 0,
				otherGoods:[],//同类推荐商品集合
				navList: [{
						state: 0,
						text: '商品介绍',
						loadingType: 'more',
						commentList: [],
					},
					{
						state: 1,
						text: '图文详情',
						loadingType: 'more',
						commentList: [],
					},
					
				],
				favorite: true,
				shareList: [],
				goodsList: [],
				specLists: [],
				ZSACTIVITY: '',
				ZSCOUPONNUM: '',
				ZSDEDUNUM: '',
				ZSPOINTNUM: '',
				img:'',
				res:'',
				comment:'',
				commentsize:'',
				commentimg:'',
				type:'',
				teamList:[],
				// #ifdef H5
				val: '', // 要生成的二维码值
				size: 300, // 二维码大小
				unit: 'upx', // 单位
				onval: true,
				loadMake: true, // 组件加载完成后自动生成二维码
				src: '' ,// 二维码生成后的图片地址或base64
				// #endif
				
				userid :'',
				teamSize:0,
				showQr:'none',
			};
		},
		async onLoad(options){
			
			
			//接收传值,id里面放的是标题，因为测试数据并没写id 
			console.log("团购商品页接受的参数",options)
			if(options.ID){
				
				this.id = options.ID;
				this.loadData(this.id);
				this.loadComm(this.id);
				this.img = getApp().globalData.imageAddress;
			
				console.log(">>>>>>>>>>>>>>>>",options.userId)
				if(options.userId==undefined || options.userId=='undefined'){
					console.log(">>>>>>>>>>>>>>>>",options.userId)
					this.loadTeam(0);
				}else{
					uni.setStorageSync("inviteid",options.userId)
					if(uni.getStorageSync('userInfo')&&uni.getStorageSync('userInfo').USER&&uni.getStorageSync('userInfo').USER.ID){
						if(options.userId == uni.getStorageSync('userInfo').USER.ID){
							this.loadTeamLogin(options.userId);
						}else{
							this.loadTeam(options.userId);
						}
					}else{
						this.loadTeam(options.userId);
					}
				}
				// #ifdef H5
				if(isWechat()){
					if(options.isOrder==0){
						this.type="share"
					}
					this.getCode();
					// document.getElementsByClassName('uni-btn-icon')[1].innerText = "";
				}else{
					this.isWechat=false
				}
				//#endif
			}else{
				uni.redirectTo({
					url:'/pages/index/index'
				})
			}
			
			this.shareList = await this.$api.json('shareList');
			this.goodsList = await this.$api.json('goodsList');
			if(uni.getStorageSync('userInfo')&&uni.getStorageSync('userInfo').USER&&uni.getStorageSync('userInfo').USER.ID){
				this.userid = uni.getStorageSync('userInfo').USER.ID
			}else{
				this.userid = "undefined"
			}
			
			uni.startPullDownRefresh();
			// #ifdef MP
			uni.showShareMenu()
			 // #endif
			
			
		},
		onPullDownRefresh() {
			console.log('refresh');
			setTimeout(function () {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onBackPress() {
			if (this.type !== '') {
				this.type = '';
				return true;
			}
		},
		// #ifdef MP
		onShareAppMessage(res){
			console.log(">>>>>>>>>>>>",res)
			return {
			      title: this.specLists.NAME,
			      path: '/pages/product/productGroup?ID='+this.id+'&userId='+ this.userid
			}
		},
		 // #endif
		methods:{
			/**
			 * 预览图片
			 */
			previewImagess(e){
				
				var lsi = []
				lsi[0] = e
				uni.previewImage({
					current: e,
					urls: lsi
				})
			},
			add(){
				this.$http.post("/goods/detailDescribe",{
					SIGNATURE : this.SIGNATURE,
					GOODSID : this.id,
				}).then((res) => {
					this.res = res.data.OBJECT.DESCRIBE;
					
				}).catch((err)=>{
					console.log('request fail', err);
				})
			},
			 // #ifdef H5
			 //获取微信公众号code
			 getCode() {
			 	let appid = "wx0f9f6f7937087278"; //为测试号id
			 	let code = getUrlParam("code"); //是否存在code
			 	console.log(code);
			 	let local =window.location.href;
			 	if (code == null || code === "") {
			 		//不存在就打开上面的地址进行授权
			 		window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${encodeURIComponent(local)}&response_type=code&scope=snsapi_base&state=1#wechat_redirect`;
			 	} else {
			 		console.log("已获取code",code)
			 	}
			 },
			 //#endif
			list(id,COUNTNUM) {
				uni.navigateTo({
					url: `/pagesun/teamList/teamList?id=${id}&COUNTNUM=${COUNTNUM}`
				})
			},
			//商品详情页
			navToDetailPage(item) {
				//测试数据没有写id，用title代替
				console.log("/////////",item)
				let id = item.ID;
				uni.navigateTo({
					url: `/pages/product/product?id=${id}`
				})
			},
			showQrs() {
				console.log(this.showQr);
				if(this.showQr === 'show'){
					this.showQr = 'hide';
					setTimeout(() => {
						this.showQr = 'none';
					}, 250);
				}else if(this.showQr === 'none'){
					this.showQr = 'show';
				}
			},
			 // #ifdef H5
			 qrR(res) {
			 	this.src = res;
			 },
			 // #endif
			
			togglePopup(type){
				if(type == 'one'){
					if(this.type == ''){
						this.type = 'one'
					}else{
						this.type = ''
					}
				}else{
					this.type = type
				}
				console.log(this.type)
			},
			change(value) {
				this.num = value
			},
			//加载团队信息
			async loadTeam(id){
				this.$http.post("/group/teamList",{
					SIGNATURE : this.SIGNATURE,
					ID: this.id,
					USERID: id
				}).then((res) => {
					console.log("团中团>>>>>>>>>>>",res.data.OBJECT);
					this.teamList = res.data.OBJECT
				}).catch((err)=>{
					console.log('request fail', err);
				})
			},
			//加载团队信息
			async loadTeamLogin(id){
				this.$http.post("/group/teamListLogin",{
					SIGNATURE : this.SIGNATURE,
					TOKEN: uni.getStorageSync('userInfo').TOKEN,
					ID: this.id,
					USERID: id
				}).then((res) => {
					console.log("团中团>>>>>>>>>>>",res.data.OBJECT);
					if(res.data.STATE === "0" && res.statusCode === 200){
						if(res.data.OBJECT == ''){
							this.teamList.length = 0;
						}else{
							this.teamList = res.data.OBJECT
						}
					}else if(res.data.STATE != '0' && res.data.STATE != '-1' ){
						this.loadTeam(id)
					}
					
				}).catch((err)=>{
					console.log('request fail', err);
				})
			},
			//加载评价
			loadComm(id){
				this.$http.post("/goods/commentlist",{
					SIGNATURE : this.SIGNATURE,
					ID : id,
					ISONE: 1,
					ISEXCHANGE: 2
				}).then((res) => {
					console.log("评价",res.data.OBJECT);
					if(res.data.OBJECT === ''){
						this.comment = res.data.OBJECT;
					}else{
						this.comment = res.data.OBJECT.LIST
					}
					// console.log("评价",this.comment.length);
					this.commentsize = res.data.OBJECT.SIZE
					this.commentimg = res.data.OBJECT.IMAGES
				}).catch((err)=>{
					console.log('request fail', err);
				})
			},
			//请求数据
			async loadData(id){
				this.SIGNATURE = uni.getStorageSync("SIGNATURE");
				if(this.tabCurrentIndex === 0){
					this.$http.post("/group/detail",{
						SIGNATURE : this.SIGNATURE,
						GOODSID : id,
					}).then((res) => {
						console.log("res",res.data.OBJECT);
						
						if ( res.data.STATE==='-1' && res.statusCode===200 && res.data.MSG === '商品不存在'){
							uni.showModal({
								title:'该商品已下架',
								success:function(){
									uni.switchTab({
										url:'/pages/index/index'
									})
								}
							})
						}else if(res.data.STATE==='0' && res.statusCode===200){
							this.specLists = res.data.OBJECT
							// #ifdef H5
							if(isWechat()){
								publicShare1(this.specLists)
							}
							// #endif
							this.teamSize = res.data.OBJECT.GBPERSON
							this.ZSACTIVITY = res.data.OBJECT.ZSACTIVITY;
							this.ZSCOUPONNUM = res.data.OBJECT.ZSCOUPONNUM;
							this.ZSDEDUNUM = res.data.OBJECT.ZSDEDUNUM;
							this.ZSPOINTNUM = res.data.OBJECT.ZSPOINTNUM;
							uni.setStorageSync("ZSACTIVITY",this.ZSACTIVITY);
							uni.setStorageSync("ZSCOUPONNUM",this.ZSCOUPONNUM);
							uni.setStorageSync("ZSDEDUNUM",this.ZSDEDUNUM);
							uni.setStorageSync("ZSPOINTNUM",this.ZSPOINTNUM);
							
						}else{
							uni.showToast({
								title:'网络异常，请稍后重试',
								icon :'none'
							})
						}
					}).catch((err)=>{
						console.log('request fail', err);
					})
					
					this.$http.post("/goods/findOtherGoodsSamecate",{
						SIGNATURE : this.SIGNATURE,
						GOODSID : id,
						PAGE:1,
					}).then((res) => {
						this.otherGoods=res.data.OBJECT;
					}).catch((err)=>{
						console.log('request fail', err);
					})
					
				}else {
					this.$http.post("/goods/detailDescribe",{
						SIGNATURE : this.SIGNATURE,
						GOODSID : id,
					}).then((res) => {
						this.res = res.data.OBJECT.DESCRIBE;
						
					}).catch((err)=>{
						console.log('request fail', err);
					})
				}
				
			},
			//swiper 切换
			changeTab(e){
				this.tabCurrentIndex = e.target.current;
				this.loadData(this.id);
			},
			//顶部tab点击
			tabClick(index){
				console.log(index);
				this.tabCurrentIndex = index;
			},
			//同类推荐页面
			navToNewproductPage(){
				this.$http.post("/goods/queryGoodsCate",{
					SIGNATURE : this.SIGNATURE,
					GOODSID : this.id,
					
				}).then((res) => {
					uni.navigateTo({
						url: '/pages/product/list?fid='+res.data.OBJECT.CATEGORYONID+'&sid='+res.data.OBJECT.CATEGORYTWID+'&tid='+res.data.OBJECT.CATEGORYTHID
					})
				}).catch((err)=>{
					console.log('request fail', err);
				})
			},
			//跳转规则页面
			navToRule(){
				uni.navigateTo({
					url:"/pagesun/groupbuy/groupBuyRule/groupBuyRule"
				})
			},
			//分享
			share(){
				this.$refs.share.toggleMask();	
			},
			share1(){
				let count = getApp().globalData.http+ '/h5/#/pages/product/productGroup?ID='+this.id+'&userId='+ this.userid
				 this.val =count
				this.type = 'two'
			},
			back() {
				if(History.length<3){
					uni.showToast({
						title:'无上级页面，请跳转首页',
						icon:'none'
					})
					uni.switchTab({
						url:'/pages/index/index'
					})
				}else{
					history.back()
				}
			},
			//收藏
			toFavorite(){
				this.favorite = !this.favorite;
			},
			buy(isGroup,teamNum){
				console.log(">>>>>>>>>>>>>>>>>>>>>>>>>"+isGroup,teamNum);
				if(this.specLists.COUNTNUM==0){
					uni.showModal({
						title: '提示',
						content: '该商品已抢光',
					})
				}else{
					//判断是否登录
					// let userInfo = uni.getStorageSync('userInfo') || '';
					//如果userInfo得到空值，那么未登录
					if(uni.getStorageSync('userInfo')){
						this.$http.post("/group/check",{
							SIGNATURE : uni.getStorageSync("SIGNATURE"),
							TOKEN: uni.getStorageSync('userInfo').TOKEN,
							GOODSID: this.id
						}).then(e=>{
							console.log(">>>>>>>>>>>>>>>>",e);
							if(e.data.STATE === '0' && e.statusCode === 200){
								if(e.data.OBJECT.CHECK=="ISCHECK"&&isGroup==2){
									const goodsId=this.id
									uni.showModal({
										content:"确定邀请开始免单奖励？",
										success: function (res) {
											if (res.confirm) {
												console.log('用户点击确定');
												// #ifdef H5
												if(isWechat()){
													uni.redirectTo({
														url: '/pages/product/productGroup?ID='+goodsId+'&userId='+uni.getStorageSync('userInfo').USER.ID+'&isOrder=0'
													})
												}else{
													uni.redirectTo({
														url: '/pages/product/productGroup?ID='+goodsId+'&userId='+uni.getStorageSync('userInfo').USER.ID
													})
												}
												// #endif
											} else if (res.cancel) {
												console.log('用户点击取消');
											}
										}
									}) 
								}else{
									if(teamNum == undefined){
										uni.navigateTo({
											url: `/pages/order/createOrderGroup?id=`+this.id+"&num=1"+"&isGroup="+isGroup
										})
									}else{
										uni.navigateTo({
											url: `/pages/order/createOrderGroup?id=`+this.id+"&num=1"+"&isGroup="+isGroup+"&teamNum="+teamNum
										})
									}
								}
							}else if(e.data.STATE=='905'){
								uni.showModal({
									content:"已在其他设备登录，请重新登录",
									success: function (res) {
										if (res.confirm) {
											uni.navigateTo({
												url:'/pages/public/login1'
											})
										} else if (res.cancel) {
											console.log('用户点击取消');
										}
									}
								})
							}else{
								uni.showToast({title:e.data.MSG, icon:"none"});
							}
						}).catch(err =>{
							console.log('request fail', err);
						})
						
					}else{
						// #ifdef MP-WEIXIN
						uni.showModal({
							content:'请先登录',
							success: function (res) {
							        if (res.confirm) {
							            uni.switchTab({
							            	url:"/pages/user/user"
							            })
							        } else if (res.cancel) {
							            console.log('用户点击取消');
							        }
							    }
						})
						// #endif
						// #ifndef MP-WEIXIN
						uni.navigateTo({
							url: "/pages/public/login1"
						})
						// #endif
					}
				}
				
				
			},
			stopPrevent(){}
			
		},
		// #ifndef MP
		
		//点击导航栏 buttons 时触发
		onNavigationBarButtonTap(e) {
			// this.$refs.share.toggleMask();	
			let count = getApp().globalData.http+ '/h5/#/pages/product/productGroup?ID='+this.id+'&userId='+ this.userid
			 this.val =count
			this.type = 'two'
		},
		// #endif
	}
	// #ifdef H5
	// 判断是否为公众号模拟器环境
	const isWechat = () => {
		return String(navigator.userAgent.toLowerCase().match(/MicroMessenger/i)) === "micromessenger";
	}
	// 判断公众号截取code
	const getUrlParam = (name) => {
		let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
		let r = window.location.search.substr(1).match(reg);
		if (r != null) {
			return unescape(r[2]);
		}
		return null;
	}
	//获取微信公众号的配置
	let publicShare1=(goods)=>{
		console.log("进入方法未发送请求")
		var userid='undefined';
		if(uni.getStorageSync('userInfo')&&uni.getStorageSync('userInfo').USER&&uni.getStorageSync('userInfo').USER.ID){
			userid = uni.getStorageSync('userInfo').USER.ID
		}
		uni.request({
			url: getApp().globalData.http+'/common/getConfig', //仅为示例，并非真实接口地址。
			data: {
				SIGNATURE : uni.getStorageSync('SIGNATURE'),
				URL:window.location.href,
			},
			header: {
				'content-type':'application/x-www-form-urlencoded',
			},
			success: (s) => {
				
				console.log('发送请求成功',s);
				jweixin.config({
					 debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
					 appId: s.data.OBJECT.APPID, // 必填，公众号的唯一标识
					 timestamp: s.data.OBJECT.TIMESTAMP, // 必填，生成签名的时间戳
					 nonceStr: s.data.OBJECT.NONCESTR, // 必填，生成签名的随机串
					 signature: s.data.OBJECT.SIGNATURE, // 必填，签名，见附录1
					 jsApiList: ['updateAppMessageShareData','updateTimelineShareData']
				});	
				jweixin.ready(function(){
				// TODO
					console.log("进入jweixin.ready方法",goods);
					
					
					jweixin.updateAppMessageShareData({
						title: goods.NAME, // 分享标题				 
						desc: goods.SHORTINFO, // 分享描述				 
						link: getApp().globalData.http+ '/h5/#/pages/product/productGroup?ID='+goods.ID+'&userId='+ userid, // 分享链接				 
						imgUrl: getApp().globalData.imageAddress+goods.THUMB, // 分享图标				 
						success: function () {},				 
					});	
					jweixin.updateTimelineShareData({
						title: goods.NAME, // 分享标题				 
						desc: goods.SHORTINFO, // 分享描述				 
						link: getApp().globalData.http+ '/h5/#/pages/product/productGroup?ID='+goods.ID+'&userId='+ userid, // 分享链接				 
						imgUrl: getApp().globalData.imageAddress+goods.THUMB, // 分享图标				 
						success: function () {},				 
					});	
				})
			}
		})
	}

	// #endif
</script>

<style lang='scss'>
	page, .container{
		background: $page-color-base;
		padding-bottom: 100upx;
		height: 100%;
		.swiper-Demo{
			height: 100%;
			.list-scroll-content{
				height: 100%;
			}
		}
	}
	.popups{
		position: absolute;
		background: #fff;
		width: 450upx;
		height: 500upx;
		font-size:35upx;
		text-align:center;
		padding-top:10upx;
		.popupimg{
			margin-top: 20upx;
			width: 400upx;
			height: 400upx;
			border: 2upx solid #9D9D9D;
		}
		.yticon{
			position: absolute;
			color: #EBEDF0;
			background-color:  #999999;
			top: 10upx;
			left: 410upx;
			border-radius: 50upx;
		}
	}
	/* #ifdef H5 */
	.share{
		text-align: center;
		color: #E02E24;
		background: #fff;
		height:520upx;
		width: 500upx;
		border: 5upx solid #F0AD4E;
		background: rgba(0, 0, 0, 0.05);
		.qrimg-i{
			position: absolute;
			padding: 10upx 30upx 30upx 30upx;
			margin: -230upx 10upx 0upx 70upx;
		}
	}
	.share1{
		font-size: 30upx;
	}
	/* #endif */
	
	
	
	
	.form{
		position: fixed;
		bottom: 100upx;
		left: 540upx;
		width: 215upx;
		.add-cart-btn{
			display:flex;
			background-color: #FA436A;
			height: 90upx;
			color: #fff;
			border-bottom: 2upx solid #909399;
			.text{
				font-size: $font-base + 10upx;
				padding-left: 60upx;
				padding-top: 20upx;
			}
		}
		
	}
	
	.icon-you{
		font-size: $font-base + 2upx;
		color: #888;
	}
	.carousel {
		height: 750upx;
		position:relative;
		
		.swiper{
			height: 100%;
		}
		.image-wrapper{
			width: 100%;
			height: 100%;
		}
		.swiper-item {
			display: flex;
			justify-content: center;
			align-content: center;
			height: 750upx;
			overflow: hidden;
			image {
				width: 100%;
				height: 100%;
			}
		}
		
	}
	
	/* 标题简介 */
	.introduce-section{
		background: #fff;
		padding: 20upx 30upx;
		
		.title{
			font-size: 32upx;
			color: $font-color-dark;
			height: 50upx;
			line-height: 50upx;
		}
		.un-title{
			white-space: nowrap;
			overflow: hidden;
			text-overflow: ellipsis;
			font-size: 32upx;
			.text{
				font-size: 20upx;
				position: absolute;
				right: 50upx;
				color: #B6B6B6;
			}
			.team1{
				display: flex;
				margin: 10upx 0upx;
				.team{
					width: 180upx;
					border: 2upx solid $uni-color-primary;
					border-radius: 10upx;
					.yticon{
						color: $uni-color-primary;
						padding-right: 10upx;
						padding-left: 10upx;
					}
					
				}
				.team-text{
					font-size: 28upx;
					color: #666666;
					margin-left: 400upx;
					border: 2upx solid #666666;
					border-radius: 10upx;
					padding: 0upx 10upx;
				}
			}
			
		}
		.price-box{
			display:flex;
			align-items:baseline;
			height: 64upx;
			padding: 10upx 0;
			font-size: 26upx;
			color:$uni-color-primary;
		}
		.price{
			font-size: $font-lg + 8upx;
			font-weight: 900;
		}
		.m-price{
			margin:0 12upx;
			color: $font-color-light;
			text-decoration: line-through;
		}
		.coupon-tip{
			align-items: center;
			padding: 4upx 10upx;
			background: $uni-color-primary;
			font-size: $font-sm;
			color: #fff;
			border-radius: 6upx;
			line-height: 1;
			transform: translateY(-4upx); 
		}
		.bot-row{
			display:flex;
			align-items:center;
			height: 50upx;
			font-size: $font-sm;
			color: $font-color-light;
			text{
				flex: 1;
			}
		}
	}
	/* 分享 */
	.share-section{
		display:flex;
		align-items:center;
		color: $font-color-base;
		background: linear-gradient(left, #fdf5f6, #fbebf6);
		padding: 12upx 30upx;
		.share-icon{
			display:flex;
			align-items:center;
			width: 70upx;
			height: 30upx;
			line-height: 1;
			border: 1px solid $uni-color-primary;
			border-radius: 4upx;
			position:relative;
			overflow: hidden;
			font-size: 22upx;
			color: $uni-color-primary;
			&:after{
				content: '';
				width: 50upx;
				height: 50upx;
				border-radius: 50%;
				left: -20upx;
				top: -12upx;
				position:absolute;
				background: $uni-color-primary;
			}
		}
		.icon-xingxing{
			position:relative;
			z-index: 1;
			font-size: 24upx;
			margin-left: 2upx;
			margin-right: 10upx;
			color: #fff;
			line-height: 1;
		}
		.tit{
			font-size: $font-base;
			margin-left:10upx;
		}
		.icon-bangzhu1{
			padding: 10upx;
			font-size: 30upx;
			line-height: 1;
		}
		.share-btn{
			flex: 1;
			text-align:right;
			font-size: $font-sm;
			color: $uni-color-primary;
		}
		.icon-you{
			font-size: $font-sm;
			margin-left: 4upx;
			color: $uni-color-primary;
		}
	}
	
	.c-list{
		font-size: $font-sm + 2upx;
		color: $font-color-base;
		background: #fff;
		.c-row{
			display:flex;
			align-items:center;
			padding: 20upx 30upx;
			position:relative;
			.un-time{
				line-height: 60upx;
				margin-left: 160upx;
				text{
					color: #999999;
					font-size: 24upx;
					margin-right: 20upx;
				}
			}
		}
		.tit{
			width: 140upx;
		}
		.con{
			flex: 1;
			color: $font-color-dark;
			.selected-text{
				margin-right: 10upx;
			}
		}
		.bz-list{
			height: 40upx;
			font-size: $font-sm+2upx;
			color: $font-color-dark;
			text{
				display: inline-block;
				margin-right: 30upx;
			}
		}
		.con-list{
			flex: 1;
			display:flex;
			flex-direction: column;
			color: $font-color-dark;
			line-height: 40upx;
		}
		.red{
			color: $uni-color-primary;
		}
	}
	
	/* 评价 */
	.eva-section{
		display: flex;
		flex-direction: column;
		padding: 20upx 30upx;
		background: #fff;
		margin-top: 16upx;
		.e-header{
			display: flex;
			align-items: center;
			height: 70upx;
			font-size: $font-sm + 2upx;
			color: $font-color-light;
			.tit{
				font-size: $font-base + 2upx;
				color: $font-color-dark;
				margin-right: 4upx;
			}
			.tip{
				flex: 1;
				text-align: right;
			}
			.icon-you{
				margin-left: 10upx;
			}
		}
	}
	.eva-box{
		display: flex;
		padding: 20upx 0;
		.portrait{
			flex-shrink: 0;
			width: 80upx;
			height: 80upx;
			border-radius: 100px;
		}
		.right{
			flex: 1;
			display: flex;
			flex-direction: column;
			font-size: $font-base;
			color: $font-color-base;
			padding-left: 26upx;
			.con{
				font-size: $font-base;
				color: $font-color-dark;
				padding: 20upx 0;
			}
			.bot{
				display: flex;
				justify-content: space-between;
				font-size: $font-sm;
				color:$font-color-light;
			}
			.commimg{
				display:flex;
				margin-top: 20upx;
				.image{
					margin-right: 20upx;
					width: 150upx;
					height: 150upx;
				}
			}
		}
	}
	/* 团购 */
	.group-list{
		display: flex;
		border-top: 1upx solid #EBEEF5;
		padding-top : 20upx;
		padding-buttom : 10upx;
		padding-left : 50upx;
		.group-image{
			.group-image-item{
				width: 80upx;
				height: 80upx;
				border-radius: 100%;
				margin-left: -60upx;
			}
		}
		.attr{
			position: absolute;
			left: 180upx;
			font-size: 35upx;
			margin-top: 18upx;
		}
		.group-text{
			position: absolute;
			margin-top: 20upx;
			font-size: 30upx;
			right: 57upx;
			color: #fff;
			z-index: 1;
		}
		.primary{
			
			position: absolute;
			text-align: center;
			margin-top: 10upx;
			right: 40upx;
			height: 65upx;
			width: 150upx;
			color: #FA436A;
			background-color: #FA436A;
		}
		
	}
	/*  详情 */
	.detail-desc{
		background: #fff;
		margin: 40upx;
		.d-header{
			display: flex;
			justify-content: center;
			align-items: center;
			height: 80upx;
			font-size: $font-base + 2upx;
			color: $font-color-dark;
			position: relative;
				
			text{
				padding: 0 20upx;
				background: #fff;
				position: relative;
				z-index: 1;
			}
			&:after{
				position: absolute;
				left: 50%;
				top: 50%;
				transform: translateX(-50%);
				width: 300upx;
				height: 0;
				content: '';
				border-bottom: 1px solid #ccc; 
			}
		}
	}
	
	
	
	/* 底部操作菜单 */
	.page-bottom{
		position:fixed;
		bottom: 0upx;
		z-index: 95;
		display: flex;
		justify-content: center;
		align-items: center;
		width: 750upx;
		height: 100upx;
		/* padding-left: 30upx; */
		background: rgba(255,255,255,.9);
		box-shadow: 0 0 20upx 0 rgba(0,0,0,.5);
		.p-b-btn{
			display:flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			font-size: $font-sm;
			color: #FF2D2D;
			width: 250upx;
			height: 80upx;
			.yticon{
				font-size: 40upx;
				line-height: 48upx;
				color:#FF2D2D;
			}
			&.active, &.active .yticon{
				color: #FFB5B5;
			}
			
			.icon-shoucang{
				font-size: 46upx;
			}
		}
		.action-btn-group{
			display: flex;
			height: 100upx;
			width: 975upx;
			text-align: center;
			/* border-radius: 100px; */
			overflow: hidden;
			/* box-shadow: 0 20upx 40upx -16upx #E02E24; */
			/* box-shadow: 1px 2px 5px #E02E24; */
			background: #E02E24;
			/* background: linear-gradient(to right, #ffac30,#fa436a,#F56C6C); */
			margin-left: 0upx;
			position:relative;
			/* &:after{
				content: '';
				position:absolute;
				top: 50%;
				right: 50%;
				transform: translateY(-50%);
				height: 28upx;
				width: 0;
				border-right: 1px solid rgba(255,255,255,.5);
			} */
			.action-btn{
				
				/* display:flex; */
				align-items: center;
				justify-content: center;
				width: 50%;
				height: 100%;
				font-size: $font-base ;
				padding: 0;
				border-radius: 0;
				background: transparent;
				background-color: #FFB5B5;
				color: #fff;
				padding-top: 10upx;
			}
			.add-cart-btn{
				align-items: center;
				background-color: #FA436A;
				font-size: $font-base ;
				width: 50%;
				height:100%;
				border-radius: 0;
				color: #fff;
				padding-top: 10upx;
			}
			.add-cart-btn1{
				margin-left: -210upx;
				align-items: center;
				background-color: #FA436A;
				font-size: $font-base ;
				width: 100%;
				height:100%;
				border-radius: 0;
				color: #fff;
				padding-top: 10upx;
			}
		}
	}
	
	/* 新鲜好物 */
	.new-section{
		margin-top: 20upx;
		padding: 0upx 20upx;
		background: #fff;
		.s-header{
			text-align: center;
			padding: 30upx 0upx;
			.tit-box{
				.tit{
					font-size: $font-sm +6upx;
					color: dimgray;
				}
			}
		}
		.floor-list{
			white-space: nowrap;
		}
		.scoll-wrapper{
			display:flex;
			align-items: flex-start;
		}
		.floor-item{
			width: 220upx;
			margin: 0upx 20upx;
			font-size: $font-sm+2upx;
			text-align: center;
			image{
				margin-top: 15upx;
				margin-bottom: 20upx;
				width: 160upx;
				height: 160upx;
				border-radius: 6upx;
			}
			.price{
				color: $uni-color-primary;
			}
			.tit2{
				font-size: $font-sm;
				color: $font-color-light;
				width: 220upx;
			}
			.title2{
				font-size: 25upx;
				line-height: 40upx;
				width: 220upx;
			}
			.un-huangtuoyuan{
				z-index: 1;
				position: absolute;
				margin-left: 88px;
				width: 80upx;
				height: 40upx;
				background: inherit;
				background-color: rgba(241, 151, 54, 1);
				border-width: 1upx soild rgba(241, 151, 54, 1);
				border-radius: 42upx;
				border-bottom-left-radius: 0upx;
				-moz-box-shadow: none;
				-webkit-box-shadow: none;
				font-family: '微软雅黑';
				font-weight: 404;
				font-size: 24upx;
				color: #FFFFFF;
				text-align: center;
				/* line-height: 25upx */
			}
			
		}
		.more{
			display:flex;
			align-items: center;
			justify-content: center;
			flex-direction: column;
			flex-shrink: 0;
			width: 180upx;
			height: 180upx;
			border-radius: 6upx;
			background: #f3f3f3;
			font-size: $font-base;
			color: $font-color-light;
			text:first-child{
				margin-bottom: 4upx;
			}
		}
	}
	.navbar{
		/* border-top: 1upx solid #888; */
		margin-top: -2upx;
		display: flex;
		position:fixed;
		height: 40px;
		width: 750upx;
		background: #fff;
		/* position: relative; */
		z-index: 10;
		.nav-item{
			flex: 1;
			display: flex;
			justify-content: center;
			align-items: center;
			height: 100%;
			font-size: 15px;
			color: $font-color-dark;
			position: relative;
			&.current{
				color: $base-color;
				&:after{
					content: '';
					position: absolute;
					left: 50%;
					bottom: 0;
					transform: translateX(-50%);
					width: 44px;
					height: 0;
					border-bottom: 2px solid $base-color;
				}
			}
		}
	}
	.all{
		background-color: #f5f5f5;
		margin-top: 80upx;
	}
	.top{
		background-color: #fff;
		margin-bottom: 20upx;
		.button{
			width: 90%;
			background-color: #E02E24;
		}
		.texts{
			text-align: center;
			font-size: 25upx;
			color: #ccc;
			padding-top: 20upx;
			.text{
				padding-top: 20upx;
			}
		}
	}
	.buttom{
		margin-bottom: -90upx;
		background-color: #fff;
		margin-top: 30upx;
		padding: 0upx 40upx;
		font-size: 25upx;
		color: 	#808080;
		.top{
			font-size: 30upx;
			text-align: center;
			padding: 40upx 0upx;
		}
		.mid{
			margin: 50upx 0upx;
			.tittle{
				font-weight: 800;
				margin-bottom: 10upx;
			}
			.text{
				display: flex;
			}
		}
		.text{
			line-height: 40upx;
		}
	}
</style>
